#include "CCableDeliveryDescriptor.h"


CCableDeliveryDescriptor::CCableDeliveryDescriptor(void):IDescriptorData(DESCRIPTOR_TAG_CABLE_DELIVERY)
, m_eCastResolutionType(1)
{	
}

CCableDeliveryDescriptor::~CCableDeliveryDescriptor(void)
{
}

void CCableDeliveryDescriptor::GetData(BYTE* buff  , int &len)
{ 
/*
	unsigned char des[13]={0};
	FillIntToBCD((DWORD)(m_fFrequency * 10000), &des[2], 8);
	des[6]	= 0xFF;
	des[7]	= 0xF0 | m_byFECOuter;
	des[8]	= m_byModulation;
	FillIntToBCD((DWORD)(m_fSymbolRate * 100000), &des[9], 7);
	des[12]	= (des[12] & 0xF0) | (m_byFECInner & 0x0F);

	CBuffer stBuffer(buff,DESCRIPTOR_MAXLEN);
	PACK_DESCRIPTOR_BUFFER_START(stBuffer,DESCRIPTOR_TAG_CABLE_DELIVERY);
	stBuffer.Write(des[2]);
	stBuffer.Write(des[3]);
	stBuffer.Write(des[4]);
	stBuffer.Write(des[5]);
	stBuffer.Write(des[6]);
	stBuffer.Write(des[7]);
	stBuffer.Write(des[8]);
	stBuffer.Write(des[9]);
	stBuffer.Write(des[10]);
	stBuffer.Write(des[11]);
	stBuffer.Write(des[12]);
	len = PACK_DESCRIPTOR_BUFFER_END(stBuffer);   //11 */

	std::string			csfFrequency;
	std::string			csfSymbolRate;
	std::string			csbyModulation;
	std::string			csbyFECOuter;
	std::string			csbyFECInner; 

	csfFrequency = ConvertToString(((int)m_fFrequency)*10000);
	csfSymbolRate = ConvertToString(m_fSymbolRate*10);
	csbyModulation = ConvertToStringHex(m_byModulation);
	csbyFECOuter = ConvertToStringHex(m_byFECOuter);
	csbyFECInner = ConvertToString(m_byFECInner);

	std::string descriptor = "440B";//cable tag = 0x44; length = 0x0B;
	std::string strTemp = "";

	strTemp = csfFrequency;
	for (unsigned int i=0; i<(8-strTemp.length()); i++)
	{
		descriptor += "0";
	}
	descriptor += strTemp;

	descriptor += "FFF";
	strTemp = csbyFECOuter;
	descriptor += strTemp;

	strTemp = csbyModulation;
	for (unsigned int i=0; i<(2-strTemp.length()); i++)
	{
		descriptor += "0";
	}
	descriptor += strTemp;

	strTemp = csfSymbolRate;
	for (unsigned int i=0; i<(7-strTemp.length()); i++)
	{
		descriptor += "0";
	}
	descriptor += strTemp;

	strTemp = csbyFECInner;
	descriptor += strTemp;
	unsigned char cslen = 0;
	STR_HEX((char *)descriptor.c_str(),descriptor.length(),buff,(unsigned char*)&cslen) ;
 
	len = cslen;
}